package commands;

import nanoxml.XMLElement;
import utils.ITransmittable;

/**
 * This command represents a notification to the clients 
 * from the server that the DB has crashed.
 *
 */
public class CommandNotifyDBCrashed implements ITransmittable {

	private final String ATTR_MESSAGE = "errorMessage";
	private final String ATTR_PANEL = "Panel";
	
	private String errorMessage = null; 
	private String panel = null;
	
	public CommandNotifyDBCrashed (String mes, String pan) {
		this.errorMessage = mes;
		this.panel = pan;
	}
	
	public CommandNotifyDBCrashed (XMLElement command) {
		this.errorMessage = (String) command.getAttribute(ATTR_MESSAGE);
		this.panel = (String) command.getAttribute(ATTR_PANEL);
	}
	
	
	@Override
	public XMLElement toXML() {
		XMLElement message  = new XMLElement();
		message.setName(Commands.NOTIFY_DB_CRASHED);
		message.setAttribute(ATTR_MESSAGE, errorMessage);
		message.setAttribute(ATTR_PANEL, panel);
		return message;
	}
	
	public String getErrorMessage()
	{
		return errorMessage;
	}
	
	public String getPanel()
	{
		return panel;
	}
	
}
